import {createStore} from "vuex"
import getters from './getters'//为了更容易获取state里面的值

const files = import.meta.globEager('./modules/*.js')

//循环读取modules下面的所有js文件进行导入
const modules = Object.entries(files).reduce((modules, [path, mod]) => {
    const moduleName = path.replace(/^\.\/modules\/(.*)\.\w+$/, '$1')
    modules[moduleName] = mod.default
    return modules
}, {})

export default createStore({
    modules,
    getters
})
